/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.levelup.jdbc.main;

import java.util.Iterator;
import java.util.List;
import mvp.levelup.jdbc.dao.TestUserDao;
import mvp.levelup.jdbc.model.TestUser;

/**
 *
 * @author WORKSPOT2
 */
public class JdbcTest
{

    private static TestUserDao userDao = new TestUserDao();

    public static void main(String[] args)
    {
        List<TestUser> fromDb = userDao.getAllUsersFromDB();
        showUsers(fromDb);
        TestUser newUser = new TestUser(10, "User", 40, 12);
        boolean res = userDao.addUserToDB(newUser);
        System.out.println("RES: " + res);
        fromDb = userDao.getAllUsersFromDB();
        showUsers(fromDb);
    }

    private static void showUsers(List<TestUser> all)
    {
        Iterator<TestUser> iter = all.iterator();
        TestUser tmp;
        while (iter.hasNext())
        {
            tmp = iter.next();
            System.out.println(tmp);
        }
    }
}
